# conding = utf-8
from selenium.webdriver import ActionChains, Keys

from pages.lyz.pycache.InboundSummary import left_menu_sys, left_menu, btn_unfold, find_expected, member, member_options, \
    id_send, depot, depot_options, find_btn
from pages.page import Page


class InboundSummaryPages(Page):

    def open_sales_order(self):
        '''
        打开管理员UI，如果已经打开则不会执行单击动作
        :return:
        '''
        if self.display(left_menu) is False:  # 如果是隐藏状态则单击
            self.click(left_menu_sys)
        self.click(left_menu)

    def btn_unfold(self):
        self.click(btn_unfold)

    def id_send(self, value):
        self.send_keys(id_send, value)

    def search_result_text(self, value):
        '''
        单击查找完成后，获取查找结果
        :return:
        '''
        if value == '1014':
            return self.text(find_expected)

    def member(self):
        self.click(member)
        actions = ActionChains(self.driver)  # 定义动作链
        actions.send_keys(Keys.ENTER)  # 回车键
        actions.perform()

    def depot(self):
        self.click(depot)
        actions = ActionChains(self.driver)  # 定义动作链
        actions.send_keys(Keys.ENTER)  # 回车键
        actions.perform()

    def find_btn(self):
        self.click(find_btn)
